define(["baseAsset", "webgl"], function(baseAsset, webgl) {
	return {
		create : function(path) {
			
			function createStaticBuf(bufType, dataType, data, itemSize) {
				var gl	= webgl.gl;
				var buf = gl.createBuffer();
				gl.bindBuffer(bufType, buf);
				gl.bufferData(bufType, new dataType(data), gl.STATIC_DRAW);
				buf.itemSize = itemSize;
				buf.numItems = data.length / itemSize;
				return buf;
				
				//TODO: Error handling when creating buffer?
			}
			
			function processSource(txt, textStatus, jqXHR) {
				//Create buffers in GPU
				asset.data 			= txt;
				asset.buf			= {};
				asset.buf.pos 		= createStaticBuf(webgl.gl.ARRAY_BUFFER, Float32Array, asset.data.pos, 3);
				asset.buf.normal	= createStaticBuf(webgl.gl.ARRAY_BUFFER, Float32Array, asset.data.normal, 3);
				asset.buf.indices	= createStaticBuf(webgl.gl.ELEMENT_ARRAY_BUFFER, Uint16Array, asset.data.indices, 1);
				
				//Finished
				asset.loadState = baseAsset.loadState.LOADED;
				jqXHR.callback(asset, jqXHR.params);
			}
		
			var asset = baseAsset.create(path);
			
			asset.load = function(callback, params) {
				this.loadState 	= baseAsset.loadState.LOADING;
				var jqxhr 		= $.getJSON(this.getPath(), processSource);
				jqxhr.asset 	= this;
				jqxhr.callback 	= callback;
				jqxhr.params 	= params;
			};
			
			asset.unload = function() {
				
			};
			
			return asset;
		} 
	};
});